package com.gist.cithub.evaluate.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.gist.cithub.evaluate.entity.DetailInforEntity;
import com.gist.cithub.evaluate.service.DetailInforService;
import com.gist.common.utils.PageUtils;
import com.gist.common.utils.R;



/**
 * 
 *
 * @author lejin
 * @email sunlightcs@gmail.com
 * @date 2021-06-01 13:58:09
 */
@RestController
@RequestMapping("evaluate/detailinfor")
public class DetailInforController {
    @Autowired
    private DetailInforService detailInforService;

    /**
     * 根据serviceid查询总评估数据
     */

    @RequestMapping("/getDetailInfor/{sumid}")
    public R getSuminforBySid(@PathVariable("sumid") Integer sumid){
        List<DetailInforEntity> list  = detailInforService.getDetailInforBySumid(sumid);
        return R.ok().put("list", list);
    }


    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = detailInforService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 根据服务id查询服务信息
     * @param id  服务id
     * @return 服务信息列表detailInfor
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		DetailInforEntity detailInfor = detailInforService.getById(id);
        return R.ok().put("detailInfor", detailInfor);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody DetailInforEntity detailInfor){
		detailInforService.save(detailInfor);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DetailInforEntity detailInfor){
		detailInforService.updateById(detailInfor);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		detailInforService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
